package algorithm.poj.p2000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.StringTokenizer;


/**
 * 分析：
 * 实现：
 * 经验：
 * 教训：
 * 分类：
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P2656 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P2656.class.getResource("P2656.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		String line = stdin.readLine();
		while (line != null && !"0".equals(line)) {
			int n = Integer.valueOf(line.trim());
			int max = -1;
			int index = 0;
			for (int i = 0; i < n; i ++) {
				StringTokenizer st = new StringTokenizer(stdin.readLine());
				int a = Integer.valueOf(st.nextToken());
				int b = Integer.valueOf(st.nextToken());
				int c = a+b;
				if (c > 8 && c > max) {
					max = c;
					index = i+1;
				}
			}
			System.out.println(index);
			line = stdin.readLine();
		}
	}
}
